/**
 * 输入查询防抖函数
 * @param {Function} fn [回调函数]
 * @param {Number} delay  [防抖时间]
 */
export function debounce (fn, delay) {
  const delays = delay || 500
  let timer
  return function () {
    const th = this
    const args = arguments
    if (timer) {
      clearTimeout(timer)
    }
    timer = setTimeout(function () {
      timer = null
      fn.apply(th, args)
    }, delays)
  }
}
